﻿<AttributeUsage(AttributeTargets.Property, Inherited:=False, AllowMultiple:=False)> _
Public NotInheritable Class PickListAttribute
    Inherits Attribute

    Public Property PickListType As Type

    Public Sub New(ByVal pickListType As Type)

        ' Ensure the type passed in is of the correct type
        If pickListType.BaseType Is Nothing OrElse pickListType.BaseType IsNot GetType(BasePickList) Then
            Throw New ArgumentException("The type must be a type that extends BasePickList.", "pickListType")
        End If

        ' Set variables
        Me.PickListType = pickListType

    End Sub

    Public Function CreateInstance() As BasePickList
        Return Activator.CreateInstance(Me.PickListType)
    End Function

End Class

